/*************************************
 **   @author: 野狼上校               **
 **   @create: 2024-04-03 17:18      **
 **   @version: 1.0                  **
 *************************************/
/**  用户数据持久化 **/

import {defineStore} from 'pinia'

export const userStore = defineStore('userStore', {
    state: () => {
        return {
            token: '',
            userInfo: ''
        }
    },
    actions: {
        async setToken(token: string) {
            this.token = token;
        },
        async setUserInfo(userInfo: string) {
            this.userInfo = userInfo;
        }
    },
    persist: {
        key: "shangxiao_user",
        storage: sessionStorage,
        paths:['userInfo']
    }
})